'''
Author: xuxudong 1539731480@qq.com
Date: 2024-06-13 05:15:55
LastEditors: xuxudong 1539731480@qq.com
LastEditTime: 2024-06-13 09:28:15
FilePath: /workflowdemo/3rdpart/conanfile.py
Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
'''
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout
from conan.tools.files import get
from conan.tools.scm import Git


class WorkflowRecipe(ConanFile):
    name = "fmt"
    version = "10.2.1"  # 请使用你需要的版本
    license = "MIT"
    url = "https://github.com/fmtlib/fmt"
    description = "A modern formatting library"
    topics = ("fmt", "format", "string", "printf")
    settings = "os", "compiler", "build_type", "arch"
    default_options = {
        "fmt:header_only": False,
        "fmt:shared": False,
    }
    settings = "os", "compiler", "build_type", "arch"
    options = {"shared": [True, False], "fPIC": [True, False]}
    default_options = {"shared": False, "fPIC": True}

    def config_options(self):
        if self.settings.os == "Windows":
            del self.settings.compiler.libcxx

    def source(self):
        get(self, "https://github.com/fmtlib/fmt/releases/download/10.2.1/fmt-10.2.1.zip", strip_root=True)

    def requirements(self):
        self.requires("openssl/1.1.1w")

    def config_options(self):
        if self.settings.os == "Windows":
            del self.options.fPIC

    def configure(self):
        self.options["fmt"].header_only = False
        self.options["fmt"].shared = False

    def layout(self):
        cmake_layout(self)

    def generate(self):
        tc = CMakeToolchain(self)
        tc.variables["FMT_TEST"] = "OFF"
        tc.generate()

    def build(self):
        cmake = CMake(self)
        cmake.configure()
        cmake.build()

    def package(self):
        cmake = CMake(self)
        cmake.install()

    def package_info(self):
        self.cpp_info.libs = ["fmt"]
        self.cpp_info.libdirs = ["lib"]
        self.cpp_info.includedirs = ["include"]
        self.cpp_info.builddirs = ["lib/cmake/fmt"]
